#include<F_system.h>

//设定航班
int Sys_flight_set(F_list *list)
{   int id=8;

    
    D_List_file_print(list);

    F_data data={id,"Airbus_A350","杭州","北京",{16,45},{17,30},"45",450,160,160,'y'}; 
  /*  printf("班次\t机型\t起点站\t终点站\t起飞时间\t到达时间 \t\
           飞行时间\t票价\t载客量\t剩余座位\t是否飞");
   scanf("%d %s %s %s %02d:%02d %02d:%02d  %s %d  %d  %d  %c",\
            &data.id,data.flighttype,data.startcity,data.arrivecity,\
            &data.starttime,&data.arrivetime,data.flytime,&data.value,\
            &data.maxNUM,&data.leftbuyersa,data.whetherfly);
*/
    D_List_insert(list,data,id);
    D_List_file_print(list);

    return 0;
}





//修改航班
int Sys_flight_revise(F_list *list)
{
    int id;
   // char name;

    printf("输入航班的ID进行查找\r\n");
    scanf("%d",&id);
    
   if(EOF== D_list_up_data(list,D_List_find_id(list, id))) 
   {
     printf("没有找到ID为 %d的航班\r\n", id);
     return EOF;
   }
   D_List_file_print(list);
    return 0;
}
/**/
//修改用户
int Sys_user_revise(U_list *list,FlightSystem Flight_sys)
{   /*
    #define ADMIN_FILE "data/admin_users.txt"           // 管理员账户信息文件
    #define REGULAR_FILE "data/regular_users.txt"       // 普通用户信息文件
    #define SILVER_FILE "data/silver_members.txt"       // 银卡会员信息文件(9折) 余额 10000
    #define GOLD_FILE "data/gold_members.txt"           // 金卡会员信息文件(8折) 余额 15000
    #define PLATINUM_FILE "data/platinum_members.txt"   // 白金会员信息文件(7折) 余额 20000
    list = S_List_merge(list, Flight_sys.ADMIN_USER);    // 管理员账户信息文件
    list = S_List_merge(list, Flight_sys.REGULAR_USER);  // 普通用户信息文件
    list = S_List_merge(list, Flight_sys.SILVER_USER);   // 银卡会员信息文件 (9折)
    list = S_List_merge(list, Flight_sys.GOLD_USER);     // 金卡会员信息文件 (8折)
    list = S_List_merge(list, Flight_sys.PLATINUM_USER); // 白金会员信息文件 (7折)
*/
   // 开始登录
   // U_data log_data = Log_in(list);

    char name[32];
    printf("输入用户的姓名进行查找\r\n");
    scanf("%s",name);

    if(NULL!= S_List_find_name(Flight_sys.REGULAR_USER,name))
    {

    printf("普通用户\r\n");
    S_list_up_data(Flight_sys.REGULAR_USER,S_List_find_name(Flight_sys.REGULAR_USER,name));
    S_List_File_print(Flight_sys.REGULAR_USER,REGULAR_FILE);
    }

    if(NULL!= S_List_find_name(Flight_sys.SILVER_USER,name))
    {

    printf("银卡会员\r\n");
    S_list_up_data(Flight_sys.SILVER_USER,S_List_find_name(Flight_sys.REGULAR_USER,name));
    S_List_File_print(Flight_sys.SILVER_USER,SILVER_FILE);
    }
    if(NULL!= S_List_find_name(Flight_sys.GOLD_USER,name))
    {

    printf("金卡会员\r\n");
    S_list_up_data(Flight_sys.GOLD_USER,S_List_find_name(Flight_sys.GOLD_USER,name));
    S_List_File_print(Flight_sys.GOLD_USER,GOLD_FILE);
    }
    if(NULL!= S_List_find_name(Flight_sys.PLATINUM_USER,name))
    {

    printf("白金会员\r\n");
    S_list_up_data(Flight_sys.PLATINUM_USER,S_List_find_name(Flight_sys.PLATINUM_USER,name));
    S_List_File_print(Flight_sys.PLATINUM_USER,PLATINUM_FILE);
    }
    

    return 0;
} 


int Sys_admin_add(U_list *list,FlightSystem Flight_sys)
{


    U_data data;
        printf("增加姓名");
        scanf("%s",data.name);
        printf("增加密码");
        scanf("%s",data.passwd);

        data.grade=1;
        data.value=0;

    S_List_insert(Flight_sys.ADMIN_USER,data,1);
    S_List_File_print(Flight_sys.ADMIN_USER,ADMIN_FILE);
    return 0;

}

// printf("没有找到姓名为 %s的用户\r\n", name);
    // return EOF;
//  S_List_File_print(list,ADMIN_FILE);
/*  查找用户表
U_node *S_List_find_name(U_list *list, char *name);
*/

